package com.zmn.oms.persistence.interfaces.pay;

import com.zmn.oms.model.entity.pay.OrderPay;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author ：SongWeidong
 * @date ：2021/3/31 16:07
 * @description：支付明细
 */
public interface OrderPayDao {


    /**
     * 通过主键查询
     *
     * @param orderPayId
     * @return
     */
    OrderPay findOrderPayByKey(@Param("orderId") Long orderId, @Param("orderPayId") Long orderPayId);

    /**
     * 通过主键查询
     *
     * @param orderPayId
     * @return
     */
    OrderPay findAllOrderPayByKey(@Param("orderId") Long orderId, @Param("orderPayId") Long orderPayId);

    /**
     * @param orderId
     * @param workId
     * @param amountType
     * @param tradeType
     * @return
     */
    int countByWorkIdAndAmountType(@Param("orderId") Long orderId, @Param("workId") Long workId, @Param("amountType") Integer amountType, @Param("tradeType") Integer tradeType);

    int countByOrderIdAndWorkId(@Param("orderId") Long orderId, @Param("workId") Long workId);

    /**
     * 通过orderId查询支付
     *
     * @param orderId
     * @return
     */
    List<OrderPay> listOrderPayByOrderId(Long orderId);

    /**
     * 通过订单id集合查询支付凭证
     * @param orderIdList
     * @return
     */
    List<OrderPay> listEsOrderPayByOrderIdList(@Param("orderIdList") List<Long> orderIdList);

    /**
     * 通过订单id集合查询支付凭证
     * @param orderIdList
     * @return
     */
    List<OrderPay> listOrderPayByOrderIdList(@Param("orderIdList") List<Long> orderIdList);

    /**
     * 通过orderId，workId查询支付
     * @param orderId
     * @return
     */
    List<OrderPay> listOrderPayByOrderIdAndWorkId(@Param("orderId") Long orderId, @Param("workId") Long workId);

    /**
     * 通过orderId，workId，金额类型查询支付
     * @param orderId
     * @return
     */
    List<OrderPay> listOrderPayByOrderIdAndWorkIdAndAmountType(@Param("orderId") Long orderId, @Param("workId") Long workId, @Param("amountType") Integer amountType);

    /**
     * 通过orderId，workId查询支付（包含已删除）
     * @param orderId
     * @return
     */
    List<OrderPay> listAllOrderPayByOrderIdAndWorkId(@Param("orderId") Long orderId, @Param("workId") Long workId);

    /**
     * 保存支付记录
     *
     * @param orderPay
     * @return
     */
    void insertOrderPay(OrderPay orderPay);

    List<OrderPay> listOrderPayByOrderIdAndWorkIdsAndTradeType(@Param("orderId") Long orderId, @Param("workIds") List<Long> orderIds, @Param("tradeType") Integer tradeType);

    void saveRefundVoucher(OrderPay orderPay);

    /**
     * 修改支付记录
     *
     * @param orderPay
     * @return
     */
    int updateByPrimaryKeySelective(OrderPay orderPay);

    int deleteByWorkIdAndAmountType(@Param("orderId") Long orderId, @Param("workId") Long workId, @Param("amountType") Integer amountType, @Param("tradeType") Integer tradeType);

    OrderPay getOrderWorkRefundPay(@Param("orderId") Long orderId, @Param("workId") Long workId, @Param("tradeType") int tradeType);

    int deleteByKey(@Param("orderId") Long orderId, @Param("orderPayId") Long orderPayId);
}
